<?php
/**
 * class ProjectsController
 *
 * @author: Monica, Dragan
 * 
 */
class ProjectsController extends BaseController{
	
	
	public function bind(){
	
		$projects_ids = $this->ProjectsSqlDAO-> queryAll("projectID");
		$projects = array();
		if (!empty($_POST['project']) || !empty($projects_ids)) {
			$searches = array_merge((array)$_POST['project'], (array)$projects_ids);
			$searches = array_filter(array_unique($projects));
	
		}
		return $projects;
	
	}


	public function view($id = null) {
		$this->set("project", $this->_model->load($id));
	}
	
	
	
	
	/**
	 * Get Domain object by primry key
	 *
	 * @param String $id primary key
	 * @Return Projects 
	 */
	public function load($id){
		
	return $this->set("project", $this->_model->load($id));
		
	}

	
	public function queryByUserID($value){
		$this->set("projectList", $this->_model->queryByUserID($value));
		return $this->_model->queryByUserID($value);
	}
	
	
	
	/**
	 * Get all records from table
	 */
	public function queryAll(){
		
		//return $this->_model->queryAll();
		
		$this->set("projectList", $this->_model->queryAll());
	}
	
	/**
	 * Get all records from table ordered by field
	 * @Param $orderColumn column name
	 */
	public function queryAllOrderBy($orderColumn){
		$this->set("projectList", $this->_model->queryAllOrderBy($orderColumn));
		//return $this->_model->queryAllOrderBy($orderColumn);
	}
	
	/**
 	 * Delete record from table
 	 * @param project primary key
 	 */
	public function delete($projectID){
		
		return $this->_model->delete($projectID);
	}
	
	/**
 	 * Insert record to table
 	 *
 	 * @param Projects project
 	 */
	public function insert($project){
	return $this->_model->insert($project);
		//$this->set("projectList", $this->_model->queryAllOrderBy($orderColumn));
		
		
	}
	
	/**
	 * 
	 * @param int $project_id
	 * @param int $document_id
	 */
	public function insertProjectsfiles($project_id,$document_id){
		return $this->_model->insertProjectsfiles($project_id,$document_id);
	}
	
	/**
 	 * Update record in table
 	 *
 	 * @param Projects project
 	 */
	public function update($project)
	{
		
		$this->_model->update($project);
	}	

	/**
	 * Delete all rows
	 */
	public function clean(){
		
		return $this->_model->clean();
	}

	public function queryByProject($value){
		//return $this->_model->queryByProject($value);
		
		$this->set("projectList", $this->_model->queryByProject($value));
		
	}
	
	public function queryByDocument($value){
		//return $this->_model->queryByDocument($value);
		$this->set("projectList", $this->_model->queryByDocument($value));
	}


	public function deleteByUserID($value){
		return $this->_model->deleteByUserID($value);
	}

	public function deleteByProject($value){
		return $this->_model->deleteByProject($value);
		
	}


}
?>